﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using System.Diagnostics;

namespace MainUI
{
    public partial class SaveAsControl : RibbonApplicationUserControl
    {
        public SaveAsControl()
        {
            InitializeComponent();
            mruFolderList = new MRUArrayList(this.panelControl2, Properties.Resources.UnPin, Properties.Resources.Pin, Properties.Resources.Code_Central, false, true);
            mruFolderList.LabelClicked += mruFolderList_LabelClicked;
        }

        void mruFolderList_LabelClicked(object sender, EventArgs e)
        {
            Process.Start("explorer.exe", (string)sender);
            BackstageView.Ribbon.HideApplicationButtonContentControl();
        }

        MRUArrayList mruFolderList;

        public MRUArrayList MRUFolderList { get { return mruFolderList; } }
        private void galleryControlGallery_ItemClick(object sender, GalleryItemClickEventArgs e)
        {
            this.bsvlSaveAsItem.Text = e.Item.Caption;
            foreach (GalleryItem item in this.galleryControlClient1.Gallery.Groups[0].Items)
            {
                item.Checked = false;
            }
            e.Item.Checked = true;

            string folderName = Application.StartupPath + "\\" + MRUArrayList.MRUFolderName;

            switch (e.Item.Caption)
            {
                case "Máy tính":
                    this.panelControl2.Controls.Clear();
                    MRUFolderList.Init(folderName, Application.StartupPath);
                    break;
                case "Dropbox":
                    this.panelControl2.Controls.Clear();
                    break;
                default:
                    this.panelControl2.Controls.Clear();
                    MRUFolderList.Init(folderName, Application.StartupPath);
                    break;
            }
        }
    }
}
